package cn.dugcrs.basic.Listener;

import cn.dugcrs.basic.service.IPermissionScanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
@Slf4j
public class PermissionScanInitListener implements ServletContextListener {

    @Autowired
    private IPermissionScanService permissionScanService;
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                log.info("初始化:扫描注解 + 权限");
                permissionScanService.scanPermission();
                log.info("结束:扫描注解 + 权限");
            }
        }).start();
    }
 
    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}